/**
 * Copyright (C), 2001-2031, www.bosssof.com.cn
 * FileName: AllianceMember.java
 * Author: shixianwei
 * Date: 2024/8/12 11:18
 * Description:
 * <p>
 * History:
 * Date          Author   Version  Desc
 * 2024-01-01    bosssoft  1.0.0   initialize this file
 */
package com.bosssoft.setp.model.business.power;

import com.bosssoft.setp.handler.MemberHandler;
import com.bosssoft.setp.model.business.aliance.AlianceBusiness;
import lombok.Getter;
import lombok.Setter;
import xyz.erupt.annotation.Erupt;
import xyz.erupt.annotation.EruptField;
import xyz.erupt.annotation.sub_field.Edit;
import xyz.erupt.annotation.sub_field.EditType;
import xyz.erupt.annotation.sub_field.View;
import xyz.erupt.annotation.sub_field.sub_edit.ReferenceTableType;
import xyz.erupt.annotation.sub_field.sub_edit.Search;
import xyz.erupt.upms.model.EruptUser;
import xyz.erupt.upms.model.base.HyperModel;

import javax.persistence.*;
import java.util.Set;

/**
 * @className: AllianceMember
 * @description:
 * 加盟商人员管理
 * @author: shixianwei
 * @date: 2024/8/12 11:18
 * @since 1.0
 **/
@Entity
@Table(name = "setp_privilege_alliance_business_member")
@Erupt(
        name = "加盟商人员管理",
        dataProxy = MemberHandler.class
)
@Getter
@Setter
public class AllianceMember extends HyperModel {
    @ManyToOne
    @JoinColumn(name = "setp_mumber_link_alliance")
    @EruptField(
            views = {
                    @View(title = "加盟商名称", column = "name")
            },
            edit = @Edit(title = "加盟商",notNull = true,
                    search = @Search(vague = true),
                    type = EditType.REFERENCE_TABLE,
                    referenceTableType = @ReferenceTableType(id = "id", label = "name")
            )
    )
    private AlianceBusiness basicBusinessAllianceBusiness;

    @ManyToMany
    @JoinTable(name = "setp_mumber_link_user",
            joinColumns = @JoinColumn(name = "this_id", referencedColumnName = "id"),
            inverseJoinColumns = @JoinColumn(name = "table_id", referencedColumnName = "id"))
    @EruptField(
            edit = @Edit(
                    title = "旗下人员",
                    type = EditType.TAB_TABLE_REFER
            )
    )
    private Set<EruptUser> users;
}

